﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.JSDWF
{
    public partial class MyDWFApplyMasterList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "MyDWFApplyList";
            }
        }

        #region 属性 (查询条件)


        protected string Remark
        {
            get
            {
                return GetRequestValue<string>("Remark", "");

            }
        }

       

        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "ApplyDate" : base.orderField;
            }
        }
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "Desc" : base.orderDirection;
            }
        }



        #endregion

        protected string GetApplyState(object astate,object _aguid)
        {
            int Applystate = Convert.ToInt32(astate);
            string html = "<a href=\"JSDWF/MyDWFApplyDetailList.aspx?applyguid=" + _aguid.ToString() + "\" target=\"ajax\" rel=\"MyDWFApplyDetailListJbox\" ><b style='color:{1}'>{0}</b></a>";
            switch (Applystate)
            { 
                case 0:
                    html = string.Format(html, "审批中", "Lime");
                    break;
                case 1:
                    html = string.Format(html, "已同意", "green");
                    break;
                case 2:
                    html = string.Format(html, "已拒绝", "red");
                    break;
            }
            return html;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
            this.AddLog(Permission.查看, GetSql());
        }

        protected void DataBind()
        {

            this.rpMenu.DataSource = JSDWFApplyController.GetPagination(GetSql(), pageNum, numPerPage, SQLSort, ref TotalCount);
            this.rpMenu.DataBind();
        }
        protected string GetSql()
        {
            string wheresql = string.Format( " ApplyUserName='{0}'",base.User.UserName);

            string ItemCodeSQL = "";
            if (!string.IsNullOrEmpty(Remark))
            {
                ItemCodeSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("Remark", QueryOperatorsEnum.包含, Remark);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + ItemCodeSQL;
                }
                else
                {
                    wheresql = ItemCodeSQL;
                }
            }

            //string DOWNSQL = "";
            //if (FolderID > 0)
            //{
            //    DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("FolderID", QueryOperatorsEnum.等于, FolderID.ToString());
            //    if (!string.IsNullOrEmpty(wheresql))
            //    {
            //        wheresql += " and " + DOWNSQL;
            //    }
            //    else
            //    {
            //        wheresql = DOWNSQL;
            //    }
            //}


            return wheresql;
        }
    }
}